#ifndef CORE_GLWIDGET_H
#define CORE_GLWIDGET_H

#include "iengine.h"
#include <QtOpenGL/QGLWidget>
#include <QtCore/QTime>
#include "iostream"

namespace Core {

class Window;

class GLWidget : public QGLWidget
{
    Q_OBJECT
public:
    explicit GLWidget(QWidget *parent);
    virtual ~GLWidget();

    void resetEngine(IEngine *engine);
    
signals:
    void glInitialized();
    
public slots:
    void animate();
    void createMap();
    void loadMap();
    void saveMap() const;
    void chooseMapGenerationMethod();

protected:
    void initializeGL();
    void paintGL();
    void resizeGL(int w, int h);

    void keyPressEvent(QKeyEvent *event);
    void keyReleaseEvent(QKeyEvent *event);
    void mouseMoveEvent(QMouseEvent *event);
    void mousePressEvent(QMouseEvent *event);
    void wheelEvent(QWheelEvent *event);

    friend class Window;

private:
    QTime _time;
    IEngine *_engine;
    uint _ticksCount;
    double _ticksSummary;
};

} // namespace Core

#endif // CORE_GLWIDGET_H
